package Negocio;

import facebook4j.Facebook;
import facebook4j.FacebookException;
import facebook4j.FacebookFactory;
import facebook4j.Post;
import facebook4j.ResponseList;
import facebook4j.auth.AccessToken;
import facebook4j.internal.org.json.JSONObject;


public class MainFacebook {

	/**
	 * @param args
	 */
	private static final String FACEBOOK_ACCESS_TOKEN = "CAACEdEose0cBAK5ruUlecZCXbTlEtAUtot3porXnKUFzrS2aqZC5CzZAzZAnZCJjH6kbETzW2H0uJNWLLsiZBerOAW4VJj4a2orkhMjnqvU04ZCaofNszNbB8UgCYaJZBjSZAOsLyjHtVSmX3C9p8rlqr6ZA2QiOirRzEhP6QbZAoXPQLPi64uKShXxNHdbuPDolKP4sXfNti7U29Beabxf6ddZC";
	private static final String FACEBOOK_APP_ID = "571420369624786";
	private static final String FACEBOOK_APP_SECRET = "88cd7357189803607c7422af767f4c62";
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Facebook facebook=new FacebookFactory().getInstance();
		facebook.setOAuthAppId(FACEBOOK_APP_ID, FACEBOOK_APP_SECRET);
		facebook.setOAuthAccessToken(new AccessToken(FACEBOOK_ACCESS_TOKEN,null));
		
		
		try {
			//ResponseList<Post> results = facebook.searchPosts("Hamilton");
			int count=0;
			ResponseList<Post> results = facebook.searchPosts("Gol Espetacular mais bonito do mundo siga nosso instagram: www.instagram.com/piortimedomundo");
			for(Post post : results){
				//post.get
				count++;
				System.out.println(post.getFrom().getName()+"- "+post.getLikes()+" "+post.getComments()+" - "+post.getSharesCount());
				//post.getCreatedTime()+" - "+post.getPlace()+" - "+post.getFrom()+" - "+post.getMessage()+" - "+post.getStory()+" - "+post.getName()+" - "+post.getLink()+" - "+
				
			}
			System.out.println("Count de posts: "+count);
			System.out.println("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
			/*ResponseList<Post> results2=facebook.getFeed();
			
			for(Post post : results2){
				System.out.println(post.getCreatedTime()+" - "+post.getMessage()+" - "+post.getStory()+" - "+post.getName()+" - "+post.getLink()+" - "+post.getLikes()+" "+post.getComments().getCount());
			}
			System.out.println("kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk");
			*/
			//ResponseList<Post> results3=facebook.getPosts("Demis Gomes");
			//for(Post post : results3){
			//	System.out.println(post.getCreatedTime()+" - "+post.getMessage()+" - "+post.getStory()+" - "+post.getName()+" - "+post.getLink()+" - "+post.getLikes()+" "+post.getComments().getCount());
			//}
			//for(JSONObject ob: results2){
				//System.out.println(ob.get+" - "+post.getMessage()+" - "+post.getStory()+" - "+post.getName()+" - "+post.getLink()+" - "+post.getLikes()+" "+post.getComments().getCount());
			//}
		} catch (FacebookException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

}
